package br.gen.seam.readerInfoDatabase;

import br.gen.seam.util.readerInfoDatabase.ReaderInfoDatabase;

/**
 * 
 *
 * @author Diego Araujo | diegogomesaraujo@gmail.com
 * @version 1.0
 */
public class ReaderInfoDatabaseFactory {

    public static <T extends ReaderInfoDatabase> T factoryReaderDatabase(Class<T> clazz) throws ReaderInfoDatabaseException {
        ReaderInfoDatabase readerDatabase = null;
        try {
            readerDatabase = (T) clazz.newInstance();

        } catch (InstantiationException ex) {
            throw new ReaderInfoDatabaseException("Error when creating instance of class (" + clazz.getSimpleName() + "): "
                    + ex.getMessage(),
                    ex);
        } catch (IllegalAccessException ex) {
            throw new ReaderInfoDatabaseException("Error when accessing class (" + clazz.getSimpleName() + "): "
                    + ex.getMessage(),
                    ex);
        }
        return (T) readerDatabase;
    }
}
